Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Discord JavaScript Error Please verify that the package.json has a valid "main" entry

I'm making a discord bot from a tutorial on yt. I'm a beginner in JS programming.

const Discord = require('discord.js');

const client = new Discord.Client();

client.once('ready', () => {

console.log('Bot is online!');

});

client.login('My token');

and when i write in cmd "node ." i got this error

Error: Cannot find module 'C:\Users\48795\Desktop\DiscordBot\main.js'. Please verify that the package.json has a valid "main" entry

←[90m at tryPackage (internal/modules/cjs/loader.js:320:19)←[39m

←[90m at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)←[39m

←[90m at resolveMainPath (internal/modules/run_main.js:16:25)←[39m

←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:70:24)←[39m

←[90m at internal/main/run_main_module.js:17:47←[39m {

code: ←[32m'MODULE_NOT_FOUND'←[39m,

path: ←[32m'C:\Users\48795\Desktop\DiscordBot\package.json'←[39m,

requestPath: ←[32m'C:\Users\48795\Desktop\DiscordBot'←[39m

}

How do i fix this error?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

In your package.json, you need to put in the main field, the name of your script. In your case whatever you named your file.

about 4 years ago · Juan Pablo Isaza Relatório

0

The error tells me at least that your index/main file is different in your package.json than it really is. What is your main file called?

You should try renaming it to main.js OR just rename the main field in your package.json file.

about 4 years ago · Juan Pablo Isaza Relatório

0

In your package.json you need to make sure your "main" field points to your main.js file. Its probably looking for index.js.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda